﻿using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace HttpTunnel
{
    class RequestDetail : StringDictionary
    {
        public string RemoteIP
        {
            get { return this[RemoteIPKey]; }
            set { this[RemoteIPKey] = value; }
        }

        public string RemoteMachine
        {
            get { return this[RemoteMachineKey]; }
            set { this[RemoteMachineKey] = value; }
        }

        public string RemoteUser
        {
            get { return this[RemoteUserKey]; }
            set { this[RemoteUserKey] = value; }
        }

        public string Comment
        {
            get { return this[CommentKey]; }
            set { this[CommentKey] = value; }
        }

        public string Content
        {
            get { return this[ContentKey]; }
            set { this[ContentKey] = value; }
        }

        public string Url
        {
            get { return this[UrlKey]; }
            set { this[UrlKey] = value; }
        }

        public string Type
        {
            get { return this[TypeKey]; }
            set { this[TypeKey] = value; }
        }


        public const string RemoteIPKey = "ip";
        public const string RemoteMachineKey = "machine";
        public const string RemoteUserKey = "user";
        public const string UrlKey = "url";
        public const string TypeKey = "type";
        public const string ContentKey = "content";
        public const string CommentKey = "comment";

        public override string ToString()
        {
            var root = new XElement("root");
            foreach (string key in Keys)
            {
                var element = new XElement(key);
                element.Add(new XAttribute("value", this[key]));

                root.Add(element);
            }
            return root.ToString();
        }
    }
}
